module.exports = {
    "mcpTool": {
        "FileToPng": async (focusany, data) => {
            // focusany.showToast('MCP工具已执行:' + JSON.stringify(data));
            const imageBase64DataUrl = await focusany.callPage('FileToPng', data, {
                // autoClose: false,
            });
            if (!imageBase64DataUrl) {
                return {
                    content: [
                        {
                            type: "text",
                            text: `文件 ${data.path} 转换为图片失败。`,
                        }
                    ]
                }
            }
            return {
                content: [
                    {
                        type: "text",
                        text: `文件 ${data.path} 已经转换为图片。`,
                    },
                    {
                        type: "image",
                        data: imageBase64DataUrl.split(',')[1], // 去掉前缀 "data:image/png;base64,"
                    }
                ]
            }
        }
    }
}

